﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Options;

namespace Config1
{
  public class MyAddress
  {
    public string Address { get; set; }
    public string AddressFamily { get; set; }
    public int[] Ids { get; set; }
  }
  public class Config
  {
    public string Name { get; set; }
    public int Age { get; set; }
    public MyAddress MyAddress { get; set; }
  }
  internal class TestConfig
  {
    private readonly IOptionsSnapshot<Config> options;
    public TestConfig(IOptionsSnapshot<Config> options)
    {
      this.options = options;
    }
    public void Test()
    {
      Console.WriteLine(options.Value.Age);
      Console.WriteLine("**********");
      Console.WriteLine(options.Value.Age);
    }
  }
  public class Test2
  {
    private readonly IOptionsSnapshot<MyAddress> address;

    public Test2(IOptionsSnapshot<MyAddress> address)
    {
      this.address = address;
    }
    public void Test()
    {
      Console.WriteLine(address.Value.Address);
      Console.WriteLine(address.Value.AddressFamily);
    }
  }

  public class TestWebConfig
  {
    private readonly IOptionsSnapshot<WebConfig> optWC;
    public TestWebConfig(IOptionsSnapshot<WebConfig> optWC)
    {
      this.optWC = optWC;
    }
    public void Test()
    {
      var wc=optWC.Value;
      Console.WriteLine(wc.Conn.ConnectionString);
      Console.WriteLine(wc.Config.Age);
      Console.WriteLine(wc.Config.MyAddress.Ids[0]);
    }
  }
}
